@@ -3,8 +3,10 @@ |
||
| 3 | 3 |
from django.db import transaction |
| 4 | 4 |
from django.shortcuts import render |
| 5 | 5 |
from django_logit import logit |
| 6 |
+from django_query import get_query_value |
|
| 6 | 7 |
from json_render import json_render |
| 7 | 8 |
|
| 9 |
+from account.models import UserInfo |
|
| 8 | 10 |
from utils.home_photo_utils import get_home_photos |
| 9 | 11 |
|
| 10 | 12 |
|
@@ -17,6 +19,13 @@ def mini_preview(request): |
||
| 17 | 19 |
@logit |
| 18 | 20 |
@transaction.atomic |
| 19 | 21 |
def mini_preview2(request): |
| 22 |
+ user_id = get_query_value(request, 'user_id') |
|
| 23 |
+ |
|
| 24 |
+ try: |
|
| 25 |
+ user = UserInfo.objects.get(user_id=user_id) |
|
| 26 |
+ except UserInfo.DoesNotExist: |
|
| 27 |
+ user = None |
|
| 28 |
+ |
|
| 20 | 29 |
photos, session_photos, left = get_home_photos(request) |
| 21 | 30 |
|
| 22 | 31 |
return json_render(request, 'page/mini_preview2.html', {
|
@@ -25,4 +34,6 @@ def mini_preview2(request): |
||
| 25 | 34 |
}, unjsondumpsdict={
|
| 26 | 35 |
'session_photos': session_photos, |
| 27 | 36 |
'left': left, |
| 37 |
+ 'user_id': user_id, |
|
| 38 |
+ 'nickname': user.nickname if user else '', |
|
| 28 | 39 |
}) |
@@ -108,6 +108,20 @@ |
||
| 108 | 108 |
box-sizing: border-box; |
| 109 | 109 |
z-index: 99999; |
| 110 | 110 |
} |
| 111 |
+ |
|
| 112 |
+ .qrscan {
|
|
| 113 |
+ position: fixed; |
|
| 114 |
+ right: 10px; |
|
| 115 |
+ bottom: 10px; |
|
| 116 |
+ width: 80px; |
|
| 117 |
+ height: 80px; |
|
| 118 |
+ z-index: 99999; |
|
| 119 |
+ } |
|
| 120 |
+ |
|
| 121 |
+ .qrscan > img {
|
|
| 122 |
+ width: 100%; |
|
| 123 |
+ height: 100%; |
|
| 124 |
+ } |
|
| 111 | 125 |
</style> |
| 112 | 126 |
</head> |
| 113 | 127 |
<body> |
@@ -129,6 +143,10 @@ |
||
| 129 | 143 |
<div id="nomark" class="nomark-buy">去除水印</div> |
| 130 | 144 |
{# <div id="origin" class="origin-buy">购买原图</div>#}
|
| 131 | 145 |
</div> |
| 146 |
+ <!-- 扫一扫 --> |
|
| 147 |
+ <div id="qrscan" class="qrscan"> |
|
| 148 |
+ <img class="" src="../../static/img/qrscan.png"/> |
|
| 149 |
+ </div> |
|
| 132 | 150 |
</div> |
| 133 | 151 |
<!-- Root element of PhotoSwipe. Must have class pswp. --> |
| 134 | 152 |
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true"> |
@@ -181,7 +199,8 @@ |
||
| 181 | 199 |
<script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> |
| 182 | 200 |
<script src="//cdn.bootcss.com/photoswipe/4.1.2/photoswipe.min.js"></script> |
| 183 | 201 |
<script src="//cdn.bootcss.com/photoswipe/4.1.2/photoswipe-ui-default.min.js"></script> |
| 184 |
-<script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.3.2.js"></script> |
|
| 202 |
+<script src="//res.wx.qq.com/open/js/jweixin-1.3.2.js"></script> |
|
| 203 |
+<script src="{% static 'pai2/js/jswe-0.0.4.js' %}"></script>
|
|
| 185 | 204 |
<script> |
| 186 | 205 |
$(function () {
|
| 187 | 206 |
/** 格式化输入字符串 **/ |
@@ -236,6 +255,17 @@ |
||
| 236 | 255 |
return result; |
| 237 | 256 |
} |
| 238 | 257 |
|
| 258 |
+ function parse(paramstr) {
|
|
| 259 |
+ var ret = {},
|
|
| 260 |
+ seg = paramstr.split('&'),
|
|
| 261 |
+ len = seg.length, i = 0, s; |
|
| 262 |
+ for (; i < len; i++) {
|
|
| 263 |
+ s = seg[i].split('=');
|
|
| 264 |
+ ret[s[0]] = s[1]; |
|
| 265 |
+ } |
|
| 266 |
+ return ret |
|
| 267 |
+ } |
|
| 268 |
+ |
|
| 239 | 269 |
var GROUP_AVATAR_LIST = [ |
| 240 | 270 |
'apple', |
| 241 | 271 |
'banana', |
@@ -275,6 +305,9 @@ |
||
| 275 | 305 |
var orderId = ''; |
| 276 | 306 |
var orderQueryTimer = null; |
| 277 | 307 |
|
| 308 |
+ var user_id = '{{ user_id }}';
|
|
| 309 |
+ var nickname = '{{ nickname }}';
|
|
| 310 |
+ |
|
| 278 | 311 |
for (var i = 0; i < session_photos.length; i++) {
|
| 279 | 312 |
var photos = session_photos[i].photos; |
| 280 | 313 |
for (var j = 0; j < photos.length; j++) {
|
@@ -339,6 +372,8 @@ |
||
| 339 | 372 |
|
| 340 | 373 |
// Initializes and opens PhotoSwipe |
| 341 | 374 |
$('#photos img').click(function () {
|
| 375 |
+ $('#qrscan').hide();
|
|
| 376 |
+ |
|
| 342 | 377 |
curIdx = parseInt($(this).attr('data-idx'));
|
| 343 | 378 |
options['index'] = curIdx; |
| 344 | 379 |
var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, swipeItems, options); |
@@ -357,6 +392,7 @@ |
||
| 357 | 392 |
|
| 358 | 393 |
// Gallery starts closing |
| 359 | 394 |
gallery.listen('close', function () {
|
| 395 |
+ $('#qrscan').show();
|
|
| 360 | 396 |
$('#buy').hide();
|
| 361 | 397 |
$('#mask-thump').hide();
|
| 362 | 398 |
}); |
@@ -378,7 +414,7 @@ |
||
| 378 | 414 |
$.ajax({
|
| 379 | 415 |
url: 'f/bought', |
| 380 | 416 |
data: {
|
| 381 |
- user_id: '{{ request.GET.user_id }}',
|
|
| 417 |
+ user_id: user_id, |
|
| 382 | 418 |
photo_id: photoId, |
| 383 | 419 |
}, |
| 384 | 420 |
success: function (res) {
|
@@ -444,6 +480,75 @@ |
||
| 444 | 480 |
} |
| 445 | 481 |
}); |
| 446 | 482 |
}) |
| 483 |
+ |
|
| 484 |
+ $('#qrscan').click(function (e) {
|
|
| 485 |
+ V.scanQRCode({
|
|
| 486 |
+ needResult: 1 |
|
| 487 |
+ }); |
|
| 488 |
+ }) |
|
| 489 |
+ |
|
| 490 |
+ V.wxScanQRCodeSuccess = function (res) {
|
|
| 491 |
+ var qrcodeurl = V.parseScanQRCodeResultStr(res.resultStr); |
|
| 492 |
+ var matched = /(https{0,1}:\/\/[\w*.]+\w*)\/(\w*)\/(\w*)\?*(.*)/.exec(qrcodeurl);
|
|
| 493 |
+ // 如果匹配失败 |
|
| 494 |
+ if (!matched) {
|
|
| 495 |
+ return |
|
| 496 |
+ } |
|
| 497 |
+ matchedInfo = {
|
|
| 498 |
+ uri: matched[1], |
|
| 499 |
+ type: matched[2], |
|
| 500 |
+ id: matched[3], |
|
| 501 |
+ params: matched[4], |
|
| 502 |
+ } |
|
| 503 |
+ if (matchedInfo.type == 's') {
|
|
| 504 |
+ $.ajax({
|
|
| 505 |
+ url: '/s/join', |
|
| 506 |
+ type: 'POST', |
|
| 507 |
+ data: {
|
|
| 508 |
+ session_id: matchedInfo.id, |
|
| 509 |
+ user_id: user_id, |
|
| 510 |
+ nickname: nickname, |
|
| 511 |
+ lensman_id: parse.parse(matchedInfo.params).lensman_id, |
|
| 512 |
+ }, |
|
| 513 |
+ success: function (res) {
|
|
| 514 |
+ if (res.data.status == 200) {
|
|
| 515 |
+ window.location.reload(); |
|
| 516 |
+ } |
|
| 517 |
+ } |
|
| 518 |
+ }) |
|
| 519 |
+ } |
|
| 520 |
+ else if (matchedInfo.type == 'g') {
|
|
| 521 |
+ requests.post({
|
|
| 522 |
+ url: '/g/join', |
|
| 523 |
+ data: {
|
|
| 524 |
+ group_id: matchedInfo.id, |
|
| 525 |
+ user_id: user_id, |
|
| 526 |
+ nickname: nickname, |
|
| 527 |
+ }, |
|
| 528 |
+ success: function (res) {
|
|
| 529 |
+ if (res.data.status == 200) {
|
|
| 530 |
+ // 刷新照片 |
|
| 531 |
+ window.location.reload(); |
|
| 532 |
+ } |
|
| 533 |
+ } |
|
| 534 |
+ }) |
|
| 535 |
+ } |
|
| 536 |
+ else if (matchedInfo.type == 'tgu') {
|
|
| 537 |
+ requests.post({
|
|
| 538 |
+ url: '/tgu/join', |
|
| 539 |
+ data: {
|
|
| 540 |
+ admin_id: matchedInfo.id, |
|
| 541 |
+ user_id: user_id, |
|
| 542 |
+ }, |
|
| 543 |
+ success: function (res) {
|
|
| 544 |
+ if (res.data.status == 200) {
|
|
| 545 |
+ // 刷新照片 |
|
| 546 |
+ window.location.reload(); |
|
| 547 |
+ } |
|
| 548 |
+ } |
|
| 549 |
+ }) |
|
| 550 |
+ } |
|
| 551 |
+ } |
|
| 447 | 552 |
}) |
| 448 | 553 |
</script> |
| 449 | 554 |
</body> |
@@ -460,7 +460,7 @@ |
||
| 460 | 460 |
// 9 微信原生接口 |
| 461 | 461 |
// 9.1.1 扫描二维码并返回结果 |
| 462 | 462 |
// 9.1.2 扫描二维码并返回结果 |
| 463 |
- function scanQRCode(scan_params) {
|
|
| 463 |
+ function scanQRCode(scan_params) {
|
|
| 464 | 464 |
if ('undefined' === typeof scan_params) scan_params = {}
|
| 465 | 465 |
wx.scanQRCode({
|
| 466 | 466 |
needResult: scan_params.needResult || 0, // 默认为0,0扫描结果由微信处理,1直接返回扫描结果 |
@@ -479,7 +479,7 @@ |
||
| 479 | 479 |
|
| 480 | 480 |
// 10 微信支付接口 |
| 481 | 481 |
// 10.1 发起一个支付请求 |
| 482 |
- function chooseWXPay(wxpay_params) {
|
|
| 482 |
+ function chooseWXPay(wxpay_params) {
|
|
| 483 | 483 |
wx.chooseWXPay({
|
| 484 | 484 |
timestamp: wxpay_params.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符 |
| 485 | 485 |
nonceStr: wxpay_params.nonceStr, // 支付签名随机串,不长于 32 位 |
@@ -495,7 +495,7 @@ |
||
| 495 | 495 |
|
| 496 | 496 |
// xx 微信原生企业红包接口 |
| 497 | 497 |
// xx.1 发起一个发送原生企业红包请求 |
| 498 |
- function openEnterpriseRedPacket(wxredpack_params) {
|
|
| 498 |
+ function openEnterpriseRedPacket(wxredpack_params) {
|
|
| 499 | 499 |
wx.openEnterpriseRedPacket({
|
| 500 | 500 |
timeStamp: wxredpack_params.timeStamp, // 红包签名时间戳,注意原生企业红包接口timeStamp字段名需大写其中的S字符,而支付接口timeStamp字段名无需大写其中的S字符。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符 |
| 501 | 501 |
nonceStr: wxredpack_params.nonceStr, // 红包签名随机串,不长于 32 位 |
@@ -22,7 +22,7 @@ from django.contrib import admin |
||
| 22 | 22 |
from rest_framework import routers |
| 23 | 23 |
|
| 24 | 24 |
from account import account_views |
| 25 |
-from group import group_views, grouppage_views |
|
| 25 |
+from group import group_views, grouppage_views, groupuser_views, tourguidegroupuser_views |
|
| 26 | 26 |
from miniapp import views as mini_views |
| 27 | 27 |
from pay import views as pay_views |
| 28 | 28 |
from photo import views as photo_views |
@@ -81,6 +81,10 @@ urlpatterns += [ |
||
| 81 | 81 |
url(r'^mini/order_create$', pay_views.wx_order_create_api, name='wx_order_create_api'), # 订单创建 |
| 82 | 82 |
url(r'^mini/order_query$', pay_views.wx_order_query_api, name='wx_order_query_api'), # 订单查询补单 |
| 83 | 83 |
|
| 84 |
+ url(r'^s/join$', photo_views.session_join_api, name='session_join_api'), # Session 加群 |
|
| 85 |
+ url(r'^g/join$', groupuser_views.group_user_join_api, name='group_join_api'), # 群成员加群 |
|
| 86 |
+ url(r'^tgu/join$', tourguidegroupuser_views.tgu_group_user_join_api, name='tgu_group_user_join_api'), # 旅行团成员加团 |
|
| 87 |
+ |
|
| 84 | 88 |
url(r'^f/bought$', group_views.lensman_photo_bought, name='lensman_photo_bought'), # 摄影师照片已购买 |
| 85 | 89 |
] |
| 86 | 90 |
|